#include "player.h"
#include "weapon.h"
#include <fstream>

using namespace std;

player::player()
{
	name = "";
	gender = "";
	race = "";
	age = 0;
	eyeColour = "";
	hairColour = "";
	skinColour = "";
	playerClass = "";
	resourceName = "";
	resourceQty = 0;
	maxResource = 0;
	health = 0;
	maxHealth= 0;
	armour= 0;
	finalArmour= 0;
	numMoves = 0;
	crit= 0;
	dodge= 0;
	vitality= 0;
	strength= 0;
	dexterity= 0;
	magic = 0;
	experiance = 0;
	gold = 0;
}

player::~player()
{
}

void player::readPlayerData(string sName)
{
	ifstream characterSheet(sName + ".txt");
	if(characterSheet.is_open())
	{
		while(characterSheet.good())
		{
			characterSheet >> name >> age >> gender >> race >> eyeColour >> hairColour >> skinColour >> playerClass >> resourceName >> maxResource >> maxHealth >> armour >> crit >> dodge >> vitality >> strength >> dexterity >> magic;
		}
		characterSheet.close();
	}
	else 
		cout << "Unable to open file";

	cout << "Your character:\n" << name << "\n" << age << "\n" << gender << "\n" << race << "\n" << eyeColour << "\n" << hairColour << "\n" << skinColour << "\n" << playerClass << "\n" << maxHealth << "\n" << armour << "\n" << crit << "\n" << dodge << "\n" << vitality << "\n" << strength << "\n"  << dexterity << "\n" << magic << endl;
}

double player::getCrit()
{
	double crit = 5 * ((double)dexterity + 100) / 75;

	return crit;
}

double player::getDodge()
{
	double dodge = 5 * ((double)dexterity + 100) / 80;

	return dodge;
}

int player::getArmour()
{
	int baseArmour = 2 * dexterity + armour;

	return baseArmour;
}

int player::healthCalc()
{
	health += (vitality * 10);
	maxHealth = health;

	return health;
}

double player::getParry()
{
	return parry;
}

double player::getCounter()
{
	return counter;
}

double player::getMiss()
{
	return miss;
}

int player::getMinDmg()
{
	return minDmg = (currWeapon.getMinDmg() * (strength + 100) / 100) * 1;			// *1 at end is placeholder for DMG Modifier
}

int player::getMaxDmg()
{
	return maxDmg = (currWeapon.getMaxDmg() * (strength + 100) / 100) * 1;			// *1 at end is placeholder for DMG Modifier
}